function check(txtId,spanId,rex,str) {
    var txtObj = $(txtId);
    var sObj = $(spanId);
    if(rex.test(txtObj.val())){
        sObj.html("验证成功");
        sObj.css("color","green");
        return true;
    }else {
        sObj.html(str);
        sObj.css("color","red");
        return false;
    }
}

function checkName() {
    return check("#name",'#nameSpan',/^[\u4e00-\u9fa5]{2,}$/,'请输入两个以上的汉字');
}
function checkTel() {
    return check('#psw','#pswSpan',/^\d{6}$/,'请输入6位数字的密码');
}
function checkEmail() {
    return check('#email','#emailSpan',/^([a-zA-Z]|[0-9])+@[a-zA-Z0-9]+\.com$/,'请输入格式为xxx@xx.com的邮箱');
}
function checkBirth() {
    return check('#birthday','#birthSpan',/^\d{4}-\d{2}-\d{2}$/,'请输入格式为XXXX-XX-XX的的生日');
}

function checkForm() {
    var passName = checkName();
    var passTel = checkTel();
    var passEmail = checkEmail();
    var passBirth = checkBirth();
    return passName && passTel && passEmail && passBirth;
}
